package com.yqg.protection.cover;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * projectName:xf-service
 * author:zxf
 * time:2024/12/26 10:00
 * description:
 */

public class SystemConverter implements Converter<Integer> {

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if ("电器火灾监测系统".equals(cellData.getStringValue())) {
            return 0;
        } else if ("集中火灾报警控制器".equals(cellData.getStringValue())) {
            return 1;
        } else if ("自动灭火系统".equals(cellData.getStringValue())) {
            return 2;
        } else if ("消火栓系统".equals(cellData.getStringValue())) {
            return 3;
        } else if ("安全疏散系统".equals(cellData.getStringValue())) {
            return 4;
        } else if ("防烟排烟系统".equals(cellData.getStringValue())) {
            return 5;
        } else if ("其他设备".equals(cellData.getStringValue())) {
            return 6;
        }
        return null;
    }

    @Override
    public CellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value == 0) {
            return new CellData("电器火灾监测系统");
        } else if (value == 1) {
            return new CellData("集中火灾报警控制器");
        } else if (value == 2) {
            return new CellData("自动灭火系统");
        } else if (value == 3) {
            return new CellData("消火栓系统");
        } else if (value == 4) {
            return new CellData("安全疏散系统");
        } else if (value == 5) {
            return new CellData("防烟排烟系统");
        } else if (value == 6) {
            return new CellData("其他设备");
        }
        return null;
    }
}
